<nav class="case-detail-top">
    <div class="case-detail-top-wrap">
        <div class="container-fluid">
            <div class="row">
                <h3>{$custom.name} ({$custom.type|fc_config_name_by_key="Custom_Type",###})</h3>
                <div class="sub-title text-md">
                    <strong class="text-green">
                        目标产品：{$custom.target_product|fc_config_name_by_key="Custom_Target_Product",###}
                    </strong>
                    <span class="split"></span>
                    <span class="text-orange">
                        优先级：
                        <label>{$custom.priority|fc_config_name_by_key="Custom_Activity_Priority",###}</label>
                    </span>
                    <span class="split"></span>
                    <if condition="$custom['next_follow_time']!=null">
                        <span class="text-orange">
                            下次跟进：
                            <label>
                                        {$custom.next_follow_time|date="Y-m-d",###}
                            </label>
                        </span>
                    </if>
                </div>
                <div class="complain">
                    <if condition="fa_has_auth($custom['leader_user_id'])">
                        <a role="button" id="sign_custom" class="btn btn-link">签约</a>
                    </if>
                    <if condition="$custom['leader_user_id']==null">
                        <a role="button" id="pick_custom" class="btn btn-link">拾取</a>
                    </if>
                    <if condition="$custom['leader_user_id']!=null">
                        <a role="button" id="back_to_sea" class="btn btn-link">退回</a>
                    </if>
                </div>
            </div>
        </div>
    </div>
</nav>
<script>
    $(document).ready(function () {
        $('#back_to_sea').click(function () {
            alertify.confirm("确定要把此客户退回公海？", function (e) {
                if (e) {
                    var url = "/custom/index/back";
                    var data = "id=" + $('input[name="custom_id"]').first().val();
                    $.ajax({
                        type: "GET",
                        url: url,
                        data: data,
                        success: function (data) {
                            if (data == "0") {
                                alertify.alert("操作成功!", function () {
                                    window.location.replace("/custom/index/index");
                                });
                            } else {
                                alertify.alert("操作失败!");
                            }
                        }
                    });
                }
            });
        });
        $('#sign_custom').click(function () {
            alertify.confirm("确定要签约此客户？", function (e) {
                if (e) {
                    var url = "/custom/index/sign";
                    var data = "id=" + $('input[name="custom_id"]').first().val();
                    $.ajax({
                        type: "GET",
                        url: url,
                        data: data,
                        success: function (data) {
                            if (data == "0") {
                                alertify.alert("操作成功!", function () {
                                    window.location.replace("/custom/index/index");
                                });
                            } else {
                                alertify.alert("操作失败!");
                            }
                        }
                    });
                }
            });
        });
        $('#pick_custom').click(function () {
            alertify.confirm("确定要拾取此客户？", function (e) {
                if (e) {
                    var url = "/custom/index/pick";
                    var data = "custom_id=" + $('input[name="custom_id"]').first().val();
                    $.ajax({
                        type: "POST",
                        url: url,
                        data: data,
                        success: function (data) {
                            if (data == "0") {
                                alertify.alert("操作成功!", function () {
                                    location.reload();
                                });
                            } else {
                                alertify.alert(data);
                            }
                        }
                    });
                }
            });
        });
    });
</script>